VERSION 1.0 CLASS
BEGIN
  MultiUse = -1  'True
END
Attribute VB_Name = "CDraw"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
Option Explicit
Implements IMListPaint
Implements IMCaptionPaint

'
' Pictures painted in various places, set by owndraw.drm
'
Public m_Picture1 As PictureBox
Public m_Picture2 As PictureBox
Public m_Picture3 As PictureBox
Public m_Picture4 As PictureBox



Private Function IMCaptionPaint_CaptionHeight(Height As Integer) As Boolean
   '
   ' List/X+ control needs to know the caption height
   '
   m_Picture2.ScaleMode = Pixel
   Height = m_Picture2.ScaleHeight + 3
   '
   ' Let the control know that the return value is valid
   '
   IMCaptionPaint_CaptionHeight = True
End Function

Private Function IMCaptionPaint_PaintCaption(ByVal MPicture As MabryCtl.IMPicture) As Boolean
   Dim h As Integer
   Dim w As Integer
   Dim x As Integer
   Dim y As Integer
   Dim s As String
   
   s = "List/X Rules"
   
   MPicture.ScaleMode = Pixel
   MPicture.PaintPicture m_Picture2.Picture, 0, 0, 28, 28
   
   h = MPicture.TextHeight(s)
   w = MPicture.TextWidth(s)
   
   x = 32
   y = (MPicture.ScaleHeight - h) / 2
   
   MPicture.FontTransparent = True
   MPicture.ForeColor = RGB(255, 255, 255)
   MPicture.DrawText s, x - 1, y - 1, x + w - 1, y + h - 1, 0
   MPicture.ForeColor = RGB(0, 0, 0)
   MPicture.DrawText s, x + 1, y + 1, x + w + 1, y + h + 1, 0
   MPicture.ForeColor = RGB(192, 192, 192)
   MPicture.DrawText s, x, y, x + w, y + h, 0

   IMCaptionPaint_PaintCaption = True
End Function

Private Function IMListPaint_ItemHeight(ByVal Item As Long, ItemHeight As Integer) As Boolean
   If (Item >= 0) Then
      '
      ' List height
      '
      m_Picture1.ScaleMode = Pixel
      ItemHeight = m_Picture1.ScaleHeight
   Else
      '
      ' Heading height
      '
      m_Picture3.ScaleMode = Pixel
      ItemHeight = m_Picture3.ScaleHeight
   End If
   IMListPaint_ItemHeight = True
End Function

Private Function IMListPaint_PaintColumn(ByVal MPicture As MabryCtl.IMPicture, ByVal Item As Long, ByVal Column As Long, ByVal Selected As Boolean) As Boolean
   Dim s As String
   Dim h As Integer
   Dim w As Integer
   Dim x As Integer
   Dim y As Integer
       
   MPicture.ScaleMode = Pixel
   '
   ' Handle headings here
   '
   If (Item = -1) Then
      Select Case Column
         Case 0:
            IMListPaint_PaintColumn = True
         Case 1:
            s = "Text && Graphics!"
   
            MPicture.ScaleMode = Pixel
   
            h = MPicture.TextHeight(s)
            w = MPicture.TextWidth(s)
   
            x = 0
            y = (MPicture.ScaleHeight - h) / 2
            MPicture.DrawText s, x, y, x + w, y + h, 0
            
            m_Picture4.ScaleMode = Pixel
            MPicture.PaintPicture m_Picture4.Picture, MPicture.ScaleWidth - m_Picture4.ScaleWidth, 0, m_Picture4.ScaleWidth, m_Picture4.ScaleHeight
            IMListPaint_PaintColumn = True
         Case 2:
            MPicture.PaintPicture m_Picture3.Picture, 0, 0, 20, 23
            IMListPaint_PaintColumn = True
         Case Else
            IMListPaint_PaintColumn = False
      End Select
      Exit Function
   End If
   '
   ' Painting the list itself
   '
   IMListPaint_PaintColumn = True
   Select Case Column
      Case 0:
         '
         ' stretchs to fit column
         '
         MPicture.PaintPicture m_Picture1.Picture, 0, 0
         '
         ' no stretch
         '
'         MPicture.PaintPicture Picture1.Picture, 0, 0, 32, 32
      Case 1:
'         s = MList1.List(Item)
         MPicture.Font = m_Picture1.Font
         If (Selected) Then
            MPicture.ForeColor = RGB(255, 192, 0)
         Else
            MPicture.ForeColor = RGB(0, 192, 0)
         End If
         MPicture.DrawText "Cool!", 0, 0, MPicture.ScaleWidth, MPicture.ScaleHeight, tfSingleLine Or tfVertCenter Or tfCenter
      Case 2:
         MPicture.CurrentX = 0
         MPicture.CurrentY = 0
         MPicture.FillStyle = Item Mod 8
         MPicture.FillColor = RGB(0, 0, 192)
         MPicture.ForeColor = RGB(0, 0, 192)
         MPicture.Line -Step(MPicture.ScaleWidth, MPicture.ScaleHeight), , BF
      Case Else
         IMListPaint_PaintColumn = False
   End Select
End Function
